apiVersion: apps/v1
kind: Deployment
metadata:
  name: django-deployment
  labels:
    app: django
spec:
  replicas: 3
  selector:
    matchLabels:
      app: django
  template:
    metadata:
      labels:
        app: django
    spec:
      containers:
      - name: django-app
        image: backend:4798a6c9
        ports:
        - containerPort: 8000
        command: ["python"]
        args: ["manage.py", "runserver", "0.0.0.0:8000"]
        env:
          - name: DATABASE_NAME
            valueFrom:
              configMapKeyRef:
                name: backend-cmap
                key: database_name
          - name: DATABASE_USER
            valueFrom:
              configMapKeyRef:
                name: backend-cmap
                key: database_user
          - name: DATABASE_PASSWORD
            valueFrom:
              configMapKeyRef:
                name: backend-cmap
                key: database_password
          - name: DATABASE_HOST
            valueFrom:
              configMapKeyRef:
                name: backend-cmap
                key: database_host
          - name: DATABASE_PORT
            valueFrom:
              configMapKeyRef:
                name: backend-cmap
                key: database_port
        volumeMounts:
        - name: config
          mountPath: "/config"
          readOnly: true
      volumes:
      - name: config
        configMap:
          name: backend-cmap
